﻿<%@ Page Title="Register" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
         CodeBehind="Register.aspx.cs" Inherits="BlueMarineWebClient.Account.Register" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    <script language="javascript" type="text/javascript">

        function fncheckEmail() {

            $get("chkEmailResult").innerHTML = "<font color=gray font-size=1><i>checking..</id></font>";
            var _axService = new bluemarine.AjaxService();
            _axService.CustomerEmailCheck($get("TopMainContent_txtEmail").value, OnEmpployeeCompleted, OnEmpployeefail);
        }

        function OnEmpployeeCompleted(result) {

            if (result) {
                $get("chkEmailResult").innerHTML = "<font color=blue>This Email is available</font>";
                $get("TopMainContent_CreateUserButton").disabled = "";
            } else {
                $get("chkEmailResult").innerHTML = "<font color=red>This Email is NOT available</font>";

                $get("TopMainContent_CreateUserButton").disabled = "disabled";
            }
        }

        function OnEmpployeefail(result) {

            $get("chkEmailResult").innerHTML = "<font color=red>Checking FAIL</font>";
            var txtEmail = document.getElementById("txtEmail");
        }

    </script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="TopMainContent">
    <form id="Form1" runat="server"> 
        <asp:ScriptManager ID="ScriptManager1" runat="server">
            <services>
                <asp:servicereference Path="http://localhost:83/Service/AjaxService.svc" />
            </services>
        </asp:ScriptManager>

        <h2>
            <asp:Label ID="lblTitle" runat="server" Text="Create a New Account"></asp:Label>
        </h2>
        <p>
            Use the form below to create a new account.
        </p>
        <p>
            Passwords are required to be a minimum of <%= Membership.MinRequiredPasswordLength %>characters in length.
        </p>
        <span class="failureNotification">
            <asp:Literal ID="ErrorMessage" runat="server"></asp:Literal>
        </span>
        <asp:ValidationSummary ID="RegisterUserValidationSummary" runat="server" CssClass="failureNotification" 
                               ValidationGroup="RegisterUserValidationGroup"/>
        <div class="accountInfo">
            <fieldset class="register" >
                <legend>Account Information</legend>
                <table>
                    <tr>
                        <td>
                            <table>
                                <tr>
                                    <td><asp:Label ID="lblFullname" runat="server" Text="Label">Full-name:</asp:Label></td>
                                    <td><asp:TextBox ID="txtFullname" runat="server" CssClass="textEntry"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="FullnameRequired" runat="server" ControlToValidate="txtFullname" 
                                                                    CssClass="failureNotification" ErrorMessage="Full Name is required." ToolTip="Full Name is required." 
                                                                    ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator></td>
                                </tr>
                                <tr>
                                    <td><asp:Label ID="EmailLabel" runat="server" AssociatedControlID="txtEmail">E-mail:</asp:Label></td>
                                    <td><asp:TextBox ID="txtEmail" runat="server" CssClass="textEntry" onblur="fncheckEmail()"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="EmailRequired" runat="server" ControlToValidate="txtEmail" 
                                                                    CssClass="failureNotification" Display="Dynamic" ErrorMessage="E-mail is required." ToolTip="E-mail is required." 
                                                                    ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator>                                     
                                        <asp:RegularExpressionValidator ID="regexEmailValid" runat="server"
                                                                        CssClass="failureNotification" Display="Dynamic" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" 
                                                                        ControlToValidate="txtEmail" ErrorMessage="Invalid Email Format"
                                                                        ValidationGroup="RegisterUserValidationGroup">*</asp:RegularExpressionValidator>
                                        <div style="float: left; font-size: 10px" id="chkEmailResult"></div></td>
                                </tr>
                                <tr>
                                    <td><asp:Label ID="lblPhone" runat="server" Text="Label">Phone no:</asp:Label></td>
                                    <td><asp:TextBox ID="txtPhone" runat="server"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="PhoneRequired" runat="server" ControlToValidate="txtPhone" 
                                                                    CssClass="failureNotification" ErrorMessage="Phone nums is required." ToolTip="Phone nums is required." 
                                                                    ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator></td>
                                </tr>
                                <tr>
                                    <td><asp:Label ID="lblIN" runat="server" Text="Indentity Number">Indentity Number:</asp:Label></td>
                                    <td><asp:TextBox ID="txtIN" runat="server"></asp:TextBox>
                                        <asp:RequiredFieldValidator ID="INRequired" runat="server" ControlToValidate="txtIN" 
                                                                    CssClass="failureNotification" ErrorMessage="Indentity Nums is required." ToolTip="Indentity Nums is required." 
                                                                    ValidationGroup="RegisterUserValidationGroup">*</asp:RequiredFieldValidator></td>
                                </tr>
                                <tr>
                                    <td><asp:Label ID="lblSex" runat="server" Text="Label">Gender:</asp:Label></td>
                                    <td><asp:RadioButton ID="rbMale" Text="Male" runat="server" GroupName="sex" Checked="True" /><asp:RadioButton ID="rbFemale" Text="Female" runat="server" GroupName="sex"/></td>
                                </tr>
                            </table>
                        </td>
                        <td>

                            <table>

                            
                            
                           
                            
                            </table>
                        </td>
                    </tr>
                </table>

            </fieldset>
            <p class="submitButton">
                <asp:Button ID="CreateUserButton" runat="server" Text="Register" 
                            ValidationGroup="RegisterUserValidationGroup" 
                            onclick="CreateUserButton_Click"/>
            </p>
        </div>
    </form>
</asp:Content>